{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "import torch\n",
    "from d2l import torch as d2l\n",
    "import numpy as np\n",
    "from matplotlib_inline import backend_inline\n",
    "\n",
    "def f(x):\n",
    "    return 3 * x ** 2 - 4 * x"
   ],
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "x = np.arange(0, 3, 0.1)\n",
    "d2l.plot(x, [f(x), 2 * x - 3], 'x', 'f(x)', legend=['f(x)', \"Tangent line (x = 1)\"])"
   ],
   "id": "54722a622aae0404",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# 梯度\n",
    "## 定义\n",
    "梯度是一个向量，其分量是多变量函数相对于其所有变量的偏导数\n",
    "\n",
    "## 规则\n",
    "\n",
    "假设$\\mathbf{x}$为$n$维向量，在微分多元函数时经常使用以下规则:\n",
    "\n",
    "对于所有$\\mathbf{A} \\in \\mathbb{R}^{m \\times n}$，都有$\\nabla_{\\mathbf{x}} \\mathbf{A} \\mathbf{x} = \\mathbf{A}^\\top$\n",
    "\n",
    "对于所有$\\mathbf{A} \\in \\mathbb{R}^{n \\times m}$，都有$\\nabla_{\\mathbf{x}} \\mathbf{x}^\\top \\mathbf{A} = \\mathbf{A}$\n",
    "\n",
    "对于所有$\\mathbf{A} \\in \\mathbb{R}^{n \\times m}$，都有$\\nabla_{\\mathbf{x}} \\mathbf{x}^\\top \\mathbf{A} \\mathbf{x} = (\\mathbf{A} + \\mathbf{A}^\\top)\\mathbf{x}$\n",
    "\n",
    "\n",
    "同样，对于任何矩阵$\\mathbf{X}$，都有$\\nabla_{\\mathbf{X}} \\|\\mathbf{X} \\|_F^2 = 2\\mathbf{X}$。 正如我们之后将看到的，梯度对于设计深度学习中的优化算法有很大用处。"
   ],
   "id": "6b7f45c86bc1f7b1"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "def f2(x):\n",
    "    return x ** 3 - 1 / x\n",
    "\n",
    "x = np.arange(0.1, 3, 0.01)\n",
    "d2l.plot(x, [f2(x), 4 * x - 4], 'x', 'f2(x)', legend=['f2(x)', \"Tangent line (x = 1)\"])"
   ],
   "id": "997c735abbf091e3",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# 自动微分\n",
    "在深度学习框架中，建立好模型以后，系统会构建一个计算图，来跟踪计算是由哪些数据通过哪些操作组合起来产生的输出，自动微分能够使得系统沿着计算图反向传播梯度。\n",
    "\n",
    "反向传播的含义就是跟踪整个计算图，填充关于每个参数的偏导数。\n",
    "\n",
    "在 pytorch 中就是调用 backward 函数实现反向传播。"
   ],
   "id": "579e38657003a4d4"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# 一个简单的例子\n",
    "import torch\n",
    "x = torch.arange(4.0, requires_grad=True)\n",
    "x"
   ],
   "id": "509ad3710012c6f9",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": "x.grad",
   "id": "498bf34e3c207c",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "y = 2 * torch.dot(x, x)\n",
    "y"
   ],
   "id": "56dc03b1180d494d",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "y.backward()\n",
    "x.grad"
   ],
   "id": "d0010ae68b3bd1d7",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# y的梯度应该是 4 * x，可以用下面的式子来验证反向传播的梯度是否正确\n",
    "4 * x == x.grad"
   ],
   "id": "f0253e76487556b0",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# 非标量变量的反向传播\n",
    "x.grad.zero_() # pytorch反向传播计算出的梯度会进行累加，因此每次在计算的时候需要手动清 0\n",
    "y = x * x\n",
    "# 非标量变量在调用 backward 时需要传入一个 gradient 参数，该参数指定了微分函数关于 self 的梯度\n",
    "y.backward(torch.full((len(x),), 3))\n",
    "# y.sum().backward()\n",
    "x.grad\n"
   ],
   "id": "1f49ee7af367ebf9",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "# 分离计算：将某些计算移动到记录的计算图之外。 例如，假设y是作为x的函数计算的，而z则是作为y和x的函数计算的。\n",
    "# 想象一下，我们想计算z关于x的梯度，但由于某种原因，希望将y视为一个常数， 并且只考虑到x在y被计算后发挥的作用。\n",
    "x.grad.zero_()\n",
    "y = x * x\n",
    "u = y.detach()\n",
    "z = u * x\n",
    "print(u)\n",
    "z.sum().backward()\n",
    "x.grad == u"
   ],
   "id": "4d013d0f55895d56",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": [
    "x.grad.zero_()\n",
    "y.sum().backward()\n",
    "x.grad == 2 * x"
   ],
   "id": "225dbd23746beb1c",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-05T09:26:56.327Z",
     "start_time": "2025-09-05T09:26:56.320822Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# python控制流的梯度计算\n",
    "def f(a):\n",
    "    b = a * 2\n",
    "    while b.norm() < 1000:\n",
    "        b = b * 2\n",
    "    if b.sum() > 0:\n",
    "        c = b\n",
    "    else:\n",
    "        c = 100 * b\n",
    "    return c\n",
    "\n",
    "a = torch.randn(size=(), requires_grad=True)\n",
    "d = f(a)\n",
    "d.backward()\n",
    "print(a, d)\n",
    "a.grad == d / a"
   ],
   "id": "2e53e275a64beeed",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor(-0.3765, requires_grad=True) tensor(-154220.5781, grad_fn=<MulBackward0>)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "tensor(True)"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 28
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-05T09:31:43.418790Z",
     "start_time": "2025-09-05T09:31:43.408935Z"
    }
   },
   "cell_type": "code",
   "source": [
    "A = torch.tensor([1, 2, 3], dtype=torch.float32, requires_grad=True)\n",
    "D = f(A)\n",
    "D.sum().backward()\n",
    "print(A, D, A.grad)"
   ],
   "id": "97aa601113dd7d1a",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1., 2., 3.], requires_grad=True) tensor([ 512., 1024., 1536.], grad_fn=<MulBackward0>) tensor([512., 512., 512.])\n"
     ]
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-05T09:45:06.183122Z",
     "start_time": "2025-09-05T09:45:06.088641Z"
    }
   },
   "cell_type": "code",
   "source": [
    "input = torch.arange(-torch.pi, torch.pi, 0.01, requires_grad=True)\n",
    "sin = torch.sin(input)\n",
    "# print(sin)\n",
    "sin.backward(torch.ones(len(input)))\n",
    "grad = input.grad\n",
    "print(grad)\n",
    "d2l.plot(input.detach().numpy(), [sin.detach().numpy(), grad.detach().numpy()], 'x', 'sin(x)', legend=['sin(x)', 'grad'])"
   ],
   "id": "c7dd3e50a551af2e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([-1.0000e+00, -9.9995e-01, -9.9980e-01, -9.9955e-01, -9.9920e-01,\n",
      "        -9.9875e-01, -9.9820e-01, -9.9755e-01, -9.9680e-01, -9.9595e-01,\n",
      "        -9.9500e-01, -9.9396e-01, -9.9281e-01, -9.9156e-01, -9.9022e-01,\n",
      "        -9.8877e-01, -9.8723e-01, -9.8558e-01, -9.8384e-01, -9.8200e-01,\n",
      "        -9.8007e-01, -9.7803e-01, -9.7590e-01, -9.7367e-01, -9.7134e-01,\n",
      "        -9.6891e-01, -9.6639e-01, -9.6377e-01, -9.6106e-01, -9.5824e-01,\n",
      "        -9.5534e-01, -9.5233e-01, -9.4924e-01, -9.4604e-01, -9.4275e-01,\n",
      "        -9.3937e-01, -9.3590e-01, -9.3233e-01, -9.2866e-01, -9.2491e-01,\n",
      "        -9.2106e-01, -9.1712e-01, -9.1309e-01, -9.0897e-01, -9.0475e-01,\n",
      "        -9.0045e-01, -8.9605e-01, -8.9157e-01, -8.8699e-01, -8.8233e-01,\n",
      "        -8.7758e-01, -8.7274e-01, -8.6782e-01, -8.6281e-01, -8.5771e-01,\n",
      "        -8.5252e-01, -8.4726e-01, -8.4190e-01, -8.3646e-01, -8.3094e-01,\n",
      "        -8.2534e-01, -8.1965e-01, -8.1388e-01, -8.0803e-01, -8.0210e-01,\n",
      "        -7.9608e-01, -7.8999e-01, -7.8382e-01, -7.7757e-01, -7.7125e-01,\n",
      "        -7.6484e-01, -7.5836e-01, -7.5181e-01, -7.4517e-01, -7.3847e-01,\n",
      "        -7.3169e-01, -7.2484e-01, -7.1791e-01, -7.1091e-01, -7.0385e-01,\n",
      "        -6.9671e-01, -6.8950e-01, -6.8222e-01, -6.7488e-01, -6.6746e-01,\n",
      "        -6.5998e-01, -6.5244e-01, -6.4483e-01, -6.3715e-01, -6.2941e-01,\n",
      "        -6.2161e-01, -6.1375e-01, -6.0582e-01, -5.9783e-01, -5.8979e-01,\n",
      "        -5.8168e-01, -5.7352e-01, -5.6530e-01, -5.5702e-01, -5.4869e-01,\n",
      "        -5.4030e-01, -5.3186e-01, -5.2337e-01, -5.1482e-01, -5.0622e-01,\n",
      "        -4.9757e-01, -4.8887e-01, -4.8012e-01, -4.7133e-01, -4.6249e-01,\n",
      "        -4.5360e-01, -4.4466e-01, -4.3568e-01, -4.2666e-01, -4.1759e-01,\n",
      "        -4.0849e-01, -3.9934e-01, -3.9015e-01, -3.8092e-01, -3.7166e-01,\n",
      "        -3.6236e-01, -3.5302e-01, -3.4365e-01, -3.3424e-01, -3.2480e-01,\n",
      "        -3.1532e-01, -3.0582e-01, -2.9628e-01, -2.8672e-01, -2.7712e-01,\n",
      "        -2.6750e-01, -2.5785e-01, -2.4818e-01, -2.3848e-01, -2.2875e-01,\n",
      "        -2.1901e-01, -2.0924e-01, -1.9945e-01, -1.8964e-01, -1.7981e-01,\n",
      "        -1.6997e-01, -1.6010e-01, -1.5023e-01, -1.4033e-01, -1.3042e-01,\n",
      "        -1.2050e-01, -1.1057e-01, -1.0063e-01, -9.0672e-02, -8.0708e-02,\n",
      "        -7.0737e-02, -6.0759e-02, -5.0774e-02, -4.0785e-02, -3.0791e-02,\n",
      "        -2.0795e-02, -1.0796e-02, -7.9636e-04,  9.2035e-03,  1.9202e-02,\n",
      "         2.9200e-02,  3.9194e-02,  4.9184e-02,  5.9169e-02,  6.9148e-02,\n",
      "         7.9121e-02,  8.9085e-02,  9.9041e-02,  1.0899e-01,  1.1892e-01,\n",
      "         1.2884e-01,  1.3875e-01,  1.4865e-01,  1.5853e-01,  1.6840e-01,\n",
      "         1.7825e-01,  1.8808e-01,  1.9789e-01,  2.0768e-01,  2.1745e-01,\n",
      "         2.2720e-01,  2.3693e-01,  2.4663e-01,  2.5631e-01,  2.6596e-01,\n",
      "         2.7559e-01,  2.8519e-01,  2.9476e-01,  3.0430e-01,  3.1381e-01,\n",
      "         3.2329e-01,  3.3274e-01,  3.4215e-01,  3.5153e-01,  3.6087e-01,\n",
      "         3.7018e-01,  3.7945e-01,  3.8868e-01,  3.9788e-01,  4.0703e-01,\n",
      "         4.1615e-01,  4.2522e-01,  4.3425e-01,  4.4323e-01,  4.5218e-01,\n",
      "         4.6107e-01,  4.6992e-01,  4.7873e-01,  4.8748e-01,  4.9619e-01,\n",
      "         5.0485e-01,  5.1345e-01,  5.2201e-01,  5.3051e-01,  5.3896e-01,\n",
      "         5.4736e-01,  5.5570e-01,  5.6399e-01,  5.7221e-01,  5.8039e-01,\n",
      "         5.8850e-01,  5.9656e-01,  6.0455e-01,  6.1249e-01,  6.2036e-01,\n",
      "         6.2817e-01,  6.3592e-01,  6.4361e-01,  6.5123e-01,  6.5879e-01,\n",
      "         6.6628e-01,  6.7370e-01,  6.8106e-01,  6.8834e-01,  6.9556e-01,\n",
      "         7.0271e-01,  7.0979e-01,  7.1680e-01,  7.2374e-01,  7.3060e-01,\n",
      "         7.3739e-01,  7.4411e-01,  7.5075e-01,  7.5732e-01,  7.6382e-01,\n",
      "         7.7023e-01,  7.7657e-01,  7.8283e-01,  7.8901e-01,  7.9512e-01,\n",
      "         8.0114e-01,  8.0709e-01,  8.1295e-01,  8.1873e-01,  8.2444e-01,\n",
      "         8.3005e-01,  8.3559e-01,  8.4104e-01,  8.4641e-01,  8.5169e-01,\n",
      "         8.5689e-01,  8.6200e-01,  8.6703e-01,  8.7197e-01,  8.7682e-01,\n",
      "         8.8158e-01,  8.8626e-01,  8.9085e-01,  8.9534e-01,  8.9975e-01,\n",
      "         9.0407e-01,  9.0830e-01,  9.1244e-01,  9.1648e-01,  9.2044e-01,\n",
      "         9.2430e-01,  9.2807e-01,  9.3175e-01,  9.3533e-01,  9.3883e-01,\n",
      "         9.4222e-01,  9.4553e-01,  9.4873e-01,  9.5185e-01,  9.5486e-01,\n",
      "         9.5779e-01,  9.6061e-01,  9.6334e-01,  9.6598e-01,  9.6852e-01,\n",
      "         9.7096e-01,  9.7330e-01,  9.7555e-01,  9.7770e-01,  9.7975e-01,\n",
      "         9.8170e-01,  9.8356e-01,  9.8531e-01,  9.8697e-01,  9.8853e-01,\n",
      "         9.8999e-01,  9.9135e-01,  9.9262e-01,  9.9378e-01,  9.9484e-01,\n",
      "         9.9581e-01,  9.9667e-01,  9.9744e-01,  9.9810e-01,  9.9867e-01,\n",
      "         9.9914e-01,  9.9950e-01,  9.9977e-01,  9.9993e-01,  1.0000e+00,\n",
      "         9.9996e-01,  9.9983e-01,  9.9960e-01,  9.9926e-01,  9.9883e-01,\n",
      "         9.9829e-01,  9.9766e-01,  9.9693e-01,  9.9609e-01,  9.9516e-01,\n",
      "         9.9413e-01,  9.9300e-01,  9.9177e-01,  9.9044e-01,  9.8901e-01,\n",
      "         9.8748e-01,  9.8585e-01,  9.8413e-01,  9.8230e-01,  9.8038e-01,\n",
      "         9.7836e-01,  9.7624e-01,  9.7403e-01,  9.7172e-01,  9.6931e-01,\n",
      "         9.6680e-01,  9.6419e-01,  9.6149e-01,  9.5870e-01,  9.5581e-01,\n",
      "         9.5282e-01,  9.4974e-01,  9.4656e-01,  9.4328e-01,  9.3992e-01,\n",
      "         9.3646e-01,  9.3290e-01,  9.2925e-01,  9.2551e-01,  9.2168e-01,\n",
      "         9.1775e-01,  9.1374e-01,  9.0963e-01,  9.0543e-01,  9.0114e-01,\n",
      "         8.9676e-01,  8.9229e-01,  8.8773e-01,  8.8308e-01,  8.7835e-01,\n",
      "         8.7352e-01,  8.6861e-01,  8.6361e-01,  8.5853e-01,  8.5336e-01,\n",
      "         8.4810e-01,  8.4276e-01,  8.3733e-01,  8.3183e-01,  8.2623e-01,\n",
      "         8.2056e-01,  8.1480e-01,  8.0896e-01,  8.0305e-01,  7.9705e-01,\n",
      "         7.9097e-01,  7.8481e-01,  7.7857e-01,  7.7226e-01,  7.6587e-01,\n",
      "         7.5940e-01,  7.5285e-01,  7.4624e-01,  7.3954e-01,  7.3277e-01,\n",
      "         7.2593e-01,  7.1902e-01,  7.1203e-01,  7.0498e-01,  6.9785e-01,\n",
      "         6.9065e-01,  6.8338e-01,  6.7605e-01,  6.6865e-01,  6.6118e-01,\n",
      "         6.5364e-01,  6.4604e-01,  6.3838e-01,  6.3065e-01,  6.2286e-01,\n",
      "         6.1500e-01,  6.0709e-01,  5.9911e-01,  5.9107e-01,  5.8298e-01,\n",
      "         5.7482e-01,  5.6661e-01,  5.5834e-01,  5.5002e-01,  5.4164e-01,\n",
      "         5.3321e-01,  5.2472e-01,  5.1618e-01,  5.0759e-01,  4.9895e-01,\n",
      "         4.9026e-01,  4.8152e-01,  4.7273e-01,  4.6390e-01,  4.5501e-01,\n",
      "         4.4609e-01,  4.3712e-01,  4.2810e-01,  4.1904e-01,  4.0994e-01,\n",
      "         4.0080e-01,  3.9162e-01,  3.8240e-01,  3.7314e-01,  3.6384e-01,\n",
      "         3.5451e-01,  3.4514e-01,  3.3574e-01,  3.2630e-01,  3.1683e-01,\n",
      "         3.0733e-01,  2.9780e-01,  2.8824e-01,  2.7865e-01,  2.6903e-01,\n",
      "         2.5939e-01,  2.4972e-01,  2.4002e-01,  2.3030e-01,  2.2056e-01,\n",
      "         2.1080e-01,  2.0101e-01,  1.9120e-01,  1.8138e-01,  1.7154e-01,\n",
      "         1.6168e-01,  1.5180e-01,  1.4191e-01,  1.3200e-01,  1.2208e-01,\n",
      "         1.1215e-01,  1.0221e-01,  9.2258e-02,  8.2296e-02,  7.2326e-02,\n",
      "         6.2349e-02,  5.2365e-02,  4.2376e-02,  3.2383e-02,  2.2387e-02,\n",
      "         1.2389e-02,  2.3890e-03, -7.6109e-03, -1.7610e-02, -2.7607e-02,\n",
      "        -3.7602e-02, -4.7593e-02, -5.7579e-02, -6.7560e-02, -7.7533e-02,\n",
      "        -8.7499e-02, -9.7456e-02, -1.0740e-01, -1.1734e-01, -1.2726e-01,\n",
      "        -1.3718e-01, -1.4708e-01, -1.5696e-01, -1.6683e-01, -1.7668e-01,\n",
      "        -1.8651e-01, -1.9633e-01, -2.0612e-01, -2.1590e-01, -2.2565e-01,\n",
      "        -2.3538e-01, -2.4509e-01, -2.5477e-01, -2.6443e-01, -2.7406e-01,\n",
      "        -2.8366e-01, -2.9324e-01, -3.0278e-01, -3.1230e-01, -3.2178e-01,\n",
      "        -3.3123e-01, -3.4065e-01, -3.5004e-01, -3.5939e-01, -3.6870e-01,\n",
      "        -3.7798e-01, -3.8722e-01, -3.9642e-01, -4.0558e-01, -4.1470e-01,\n",
      "        -4.2378e-01, -4.3281e-01, -4.4181e-01, -4.5076e-01, -4.5966e-01,\n",
      "        -4.6852e-01, -4.7733e-01, -4.8609e-01, -4.9481e-01, -5.0347e-01,\n",
      "        -5.1209e-01, -5.2065e-01, -5.2916e-01, -5.3762e-01, -5.4602e-01,\n",
      "        -5.5437e-01, -5.6267e-01, -5.7091e-01, -5.7909e-01, -5.8721e-01,\n",
      "        -5.9528e-01, -6.0328e-01, -6.1123e-01, -6.1911e-01, -6.2693e-01,\n",
      "        -6.3469e-01, -6.4239e-01, -6.5002e-01, -6.5759e-01, -6.6509e-01,\n",
      "        -6.7252e-01, -6.7989e-01, -6.8719e-01, -6.9442e-01, -7.0158e-01,\n",
      "        -7.0867e-01, -7.1569e-01, -7.2264e-01, -7.2951e-01, -7.3632e-01,\n",
      "        -7.4305e-01, -7.4970e-01, -7.5628e-01, -7.6279e-01, -7.6921e-01,\n",
      "        -7.7557e-01, -7.8184e-01, -7.8804e-01, -7.9415e-01, -8.0019e-01,\n",
      "        -8.0615e-01, -8.1202e-01, -8.1782e-01, -8.2353e-01, -8.2916e-01,\n",
      "        -8.3471e-01, -8.4018e-01, -8.4556e-01, -8.5086e-01, -8.5607e-01,\n",
      "        -8.6119e-01, -8.6623e-01, -8.7119e-01, -8.7605e-01, -8.8083e-01,\n",
      "        -8.8552e-01, -8.9012e-01, -8.9463e-01, -8.9906e-01, -9.0339e-01,\n",
      "        -9.0763e-01, -9.1179e-01, -9.1585e-01, -9.1982e-01, -9.2369e-01,\n",
      "        -9.2748e-01, -9.3117e-01, -9.3477e-01, -9.3828e-01, -9.4169e-01,\n",
      "        -9.4501e-01, -9.4823e-01, -9.5136e-01, -9.5439e-01, -9.5733e-01,\n",
      "        -9.6017e-01, -9.6292e-01, -9.6557e-01, -9.6812e-01, -9.7058e-01,\n",
      "        -9.7294e-01, -9.7520e-01, -9.7736e-01, -9.7943e-01, -9.8140e-01,\n",
      "        -9.8327e-01, -9.8504e-01, -9.8671e-01, -9.8829e-01, -9.8977e-01,\n",
      "        -9.9114e-01, -9.9242e-01, -9.9360e-01, -9.9468e-01, -9.9566e-01,\n",
      "        -9.9654e-01, -9.9732e-01, -9.9800e-01, -9.9859e-01, -9.9907e-01,\n",
      "        -9.9945e-01, -9.9973e-01, -9.9991e-01, -9.9999e-01])\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 350x250 with 1 Axes>"
      ],
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"254.660937pt\" height=\"183.35625pt\" viewBox=\"0 0 254.660937 183.35625\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n <metadata>\n  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n   <cc:Work>\n    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n    <dc:date>2025-09-05T17:45:06.169924</dc:date>\n    <dc:format>image/svg+xml</dc:format>\n    <dc:creator>\n     <cc:Agent>\n      <dc:title>Matplotlib v3.7.2, https://matplotlib.org/</dc:title>\n     </cc:Agent>\n    </dc:creator>\n   </cc:Work>\n  </rdf:RDF>\n </metadata>\n <defs>\n  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n </defs>\n <g id=\"figure_1\">\n  <g id=\"patch_1\">\n   <path d=\"M 0 183.35625 \nL 254.660937 183.35625 \nL 254.660937 0 \nL 0 0 \nz\n\" style=\"fill: #ffffff\"/>\n  </g>\n  <g id=\"axes_1\">\n   <g id=\"patch_2\">\n    <path d=\"M 52.160938 145.8 \nL 247.460938 145.8 \nL 247.460938 7.2 \nL 52.160938 7.2 \nz\n\" style=\"fill: #ffffff\"/>\n   </g>\n   <g id=\"matplotlib.axis_1\">\n    <g id=\"xtick_1\">\n     <g id=\"line2d_1\">\n      <path d=\"M 93.312829 145.8 \nL 93.312829 7.2 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_2\">\n      <defs>\n       <path id=\"m6e3a57af12\" d=\"M 0 0 \nL 0 3.5 \n\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </defs>\n      <g>\n       <use xlink:href=\"#m6e3a57af12\" x=\"93.312829\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_1\">\n      <!-- −2 -->\n      <g transform=\"translate(85.941735 160.398438) scale(0.1 -0.1)\">\n       <defs>\n        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \nL 4684 2272 \nL 4684 1741 \nL 678 1741 \nL 678 2272 \nz\n\" transform=\"scale(0.015625)\"/>\n        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \nL 3431 531 \nL 3431 0 \nL 469 0 \nL 469 531 \nQ 828 903 1448 1529 \nQ 2069 2156 2228 2338 \nQ 2531 2678 2651 2914 \nQ 2772 3150 2772 3378 \nQ 2772 3750 2511 3984 \nQ 2250 4219 1831 4219 \nQ 1534 4219 1204 4116 \nQ 875 4013 500 3803 \nL 500 4441 \nQ 881 4594 1212 4672 \nQ 1544 4750 1819 4750 \nQ 2544 4750 2975 4387 \nQ 3406 4025 3406 3419 \nQ 3406 3131 3298 2873 \nQ 3191 2616 2906 2266 \nQ 2828 2175 2409 1742 \nQ 1991 1309 1228 531 \nz\n\" transform=\"scale(0.015625)\"/>\n       </defs>\n       <use xlink:href=\"#DejaVuSans-2212\"/>\n       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"xtick_2\">\n     <g id=\"line2d_3\">\n      <path d=\"M 149.855967 145.8 \nL 149.855967 7.2 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_4\">\n      <g>\n       <use xlink:href=\"#m6e3a57af12\" x=\"149.855967\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_2\">\n      <!-- 0 -->\n      <g transform=\"translate(146.674717 160.398438) scale(0.1 -0.1)\">\n       <defs>\n        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \nQ 1547 4250 1301 3770 \nQ 1056 3291 1056 2328 \nQ 1056 1369 1301 889 \nQ 1547 409 2034 409 \nQ 2525 409 2770 889 \nQ 3016 1369 3016 2328 \nQ 3016 3291 2770 3770 \nQ 2525 4250 2034 4250 \nz\nM 2034 4750 \nQ 2819 4750 3233 4129 \nQ 3647 3509 3647 2328 \nQ 3647 1150 3233 529 \nQ 2819 -91 2034 -91 \nQ 1250 -91 836 529 \nQ 422 1150 422 2328 \nQ 422 3509 836 4129 \nQ 1250 4750 2034 4750 \nz\n\" transform=\"scale(0.015625)\"/>\n       </defs>\n       <use xlink:href=\"#DejaVuSans-30\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"xtick_3\">\n     <g id=\"line2d_5\">\n      <path d=\"M 206.399106 145.8 \nL 206.399106 7.2 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_6\">\n      <g>\n       <use xlink:href=\"#m6e3a57af12\" x=\"206.399106\" y=\"145.8\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_3\">\n      <!-- 2 -->\n      <g transform=\"translate(203.217856 160.398438) scale(0.1 -0.1)\">\n       <use xlink:href=\"#DejaVuSans-32\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"text_4\">\n     <!-- x -->\n     <g transform=\"translate(146.851563 174.076563) scale(0.1 -0.1)\">\n      <defs>\n       <path id=\"DejaVuSans-78\" d=\"M 3513 3500 \nL 2247 1797 \nL 3578 0 \nL 2900 0 \nL 1881 1375 \nL 863 0 \nL 184 0 \nL 1544 1831 \nL 300 3500 \nL 978 3500 \nL 1906 2253 \nL 2834 3500 \nL 3513 3500 \nz\n\" transform=\"scale(0.015625)\"/>\n      </defs>\n      <use xlink:href=\"#DejaVuSans-78\"/>\n     </g>\n    </g>\n   </g>\n   <g id=\"matplotlib.axis_2\">\n    <g id=\"ytick_1\">\n     <g id=\"line2d_7\">\n      <path d=\"M 52.160938 139.5 \nL 247.460938 139.5 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_8\">\n      <defs>\n       <path id=\"mbcfda1ed3d\" d=\"M 0 0 \nL -3.5 0 \n\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </defs>\n      <g>\n       <use xlink:href=\"#mbcfda1ed3d\" x=\"52.160938\" y=\"139.5\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_5\">\n      <!-- −1.0 -->\n      <g transform=\"translate(20.878125 143.299219) scale(0.1 -0.1)\">\n       <defs>\n        <path id=\"DejaVuSans-31\" d=\"M 794 531 \nL 1825 531 \nL 1825 4091 \nL 703 3866 \nL 703 4441 \nL 1819 4666 \nL 2450 4666 \nL 2450 531 \nL 3481 531 \nL 3481 0 \nL 794 0 \nL 794 531 \nz\n\" transform=\"scale(0.015625)\"/>\n        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \nL 1344 794 \nL 1344 0 \nL 684 0 \nL 684 794 \nz\n\" transform=\"scale(0.015625)\"/>\n       </defs>\n       <use xlink:href=\"#DejaVuSans-2212\"/>\n       <use xlink:href=\"#DejaVuSans-31\" x=\"83.789062\"/>\n       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n       <use xlink:href=\"#DejaVuSans-30\" x=\"179.199219\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"ytick_2\">\n     <g id=\"line2d_9\">\n      <path d=\"M 52.160938 107.99998 \nL 247.460938 107.99998 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_10\">\n      <g>\n       <use xlink:href=\"#mbcfda1ed3d\" x=\"52.160938\" y=\"107.99998\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_6\">\n      <!-- −0.5 -->\n      <g transform=\"translate(20.878125 111.799199) scale(0.1 -0.1)\">\n       <defs>\n        <path id=\"DejaVuSans-35\" d=\"M 691 4666 \nL 3169 4666 \nL 3169 4134 \nL 1269 4134 \nL 1269 2991 \nQ 1406 3038 1543 3061 \nQ 1681 3084 1819 3084 \nQ 2600 3084 3056 2656 \nQ 3513 2228 3513 1497 \nQ 3513 744 3044 326 \nQ 2575 -91 1722 -91 \nQ 1428 -91 1123 -41 \nQ 819 9 494 109 \nL 494 744 \nQ 775 591 1075 516 \nQ 1375 441 1709 441 \nQ 2250 441 2565 725 \nQ 2881 1009 2881 1497 \nQ 2881 1984 2565 2268 \nQ 2250 2553 1709 2553 \nQ 1456 2553 1204 2497 \nQ 953 2441 691 2322 \nL 691 4666 \nz\n\" transform=\"scale(0.015625)\"/>\n       </defs>\n       <use xlink:href=\"#DejaVuSans-2212\"/>\n       <use xlink:href=\"#DejaVuSans-30\" x=\"83.789062\"/>\n       <use xlink:href=\"#DejaVuSans-2e\" x=\"147.412109\"/>\n       <use xlink:href=\"#DejaVuSans-35\" x=\"179.199219\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"ytick_3\">\n     <g id=\"line2d_11\">\n      <path d=\"M 52.160938 76.499961 \nL 247.460938 76.499961 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_12\">\n      <g>\n       <use xlink:href=\"#mbcfda1ed3d\" x=\"52.160938\" y=\"76.499961\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_7\">\n      <!-- 0.0 -->\n      <g transform=\"translate(29.257812 80.299179) scale(0.1 -0.1)\">\n       <use xlink:href=\"#DejaVuSans-30\"/>\n       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"ytick_4\">\n     <g id=\"line2d_13\">\n      <path d=\"M 52.160938 44.999941 \nL 247.460938 44.999941 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_14\">\n      <g>\n       <use xlink:href=\"#mbcfda1ed3d\" x=\"52.160938\" y=\"44.999941\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_8\">\n      <!-- 0.5 -->\n      <g transform=\"translate(29.257812 48.79916) scale(0.1 -0.1)\">\n       <use xlink:href=\"#DejaVuSans-30\"/>\n       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n       <use xlink:href=\"#DejaVuSans-35\" x=\"95.410156\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"ytick_5\">\n     <g id=\"line2d_15\">\n      <path d=\"M 52.160938 13.499921 \nL 247.460938 13.499921 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n     </g>\n     <g id=\"line2d_16\">\n      <g>\n       <use xlink:href=\"#mbcfda1ed3d\" x=\"52.160938\" y=\"13.499921\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n      </g>\n     </g>\n     <g id=\"text_9\">\n      <!-- 1.0 -->\n      <g transform=\"translate(29.257812 17.29914) scale(0.1 -0.1)\">\n       <use xlink:href=\"#DejaVuSans-31\"/>\n       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n      </g>\n     </g>\n    </g>\n    <g id=\"text_10\">\n     <!-- sin(x) -->\n     <g transform=\"translate(14.798438 90.523438) rotate(-90) scale(0.1 -0.1)\">\n      <defs>\n       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \nL 2834 2853 \nQ 2591 2978 2328 3040 \nQ 2066 3103 1784 3103 \nQ 1356 3103 1142 2972 \nQ 928 2841 928 2578 \nQ 928 2378 1081 2264 \nQ 1234 2150 1697 2047 \nL 1894 2003 \nQ 2506 1872 2764 1633 \nQ 3022 1394 3022 966 \nQ 3022 478 2636 193 \nQ 2250 -91 1575 -91 \nQ 1294 -91 989 -36 \nQ 684 19 347 128 \nL 347 722 \nQ 666 556 975 473 \nQ 1284 391 1588 391 \nQ 1994 391 2212 530 \nQ 2431 669 2431 922 \nQ 2431 1156 2273 1281 \nQ 2116 1406 1581 1522 \nL 1381 1569 \nQ 847 1681 609 1914 \nQ 372 2147 372 2553 \nQ 372 3047 722 3315 \nQ 1072 3584 1716 3584 \nQ 2034 3584 2315 3537 \nQ 2597 3491 2834 3397 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \nL 1178 3500 \nL 1178 0 \nL 603 0 \nL 603 3500 \nz\nM 603 4863 \nL 1178 4863 \nL 1178 4134 \nL 603 4134 \nL 603 4863 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-6e\" d=\"M 3513 2113 \nL 3513 0 \nL 2938 0 \nL 2938 2094 \nQ 2938 2591 2744 2837 \nQ 2550 3084 2163 3084 \nQ 1697 3084 1428 2787 \nQ 1159 2491 1159 1978 \nL 1159 0 \nL 581 0 \nL 581 3500 \nL 1159 3500 \nL 1159 2956 \nQ 1366 3272 1645 3428 \nQ 1925 3584 2291 3584 \nQ 2894 3584 3203 3211 \nQ 3513 2838 3513 2113 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-28\" d=\"M 1984 4856 \nQ 1566 4138 1362 3434 \nQ 1159 2731 1159 2009 \nQ 1159 1288 1364 580 \nQ 1569 -128 1984 -844 \nL 1484 -844 \nQ 1016 -109 783 600 \nQ 550 1309 550 2009 \nQ 550 2706 781 3412 \nQ 1013 4119 1484 4856 \nL 1984 4856 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-29\" d=\"M 513 4856 \nL 1013 4856 \nQ 1481 4119 1714 3412 \nQ 1947 2706 1947 2009 \nQ 1947 1309 1714 600 \nQ 1481 -109 1013 -844 \nL 513 -844 \nQ 928 -128 1133 580 \nQ 1338 1288 1338 2009 \nQ 1338 2731 1133 3434 \nQ 928 4138 513 4856 \nz\n\" transform=\"scale(0.015625)\"/>\n      </defs>\n      <use xlink:href=\"#DejaVuSans-73\"/>\n      <use xlink:href=\"#DejaVuSans-69\" x=\"52.099609\"/>\n      <use xlink:href=\"#DejaVuSans-6e\" x=\"79.882812\"/>\n      <use xlink:href=\"#DejaVuSans-28\" x=\"143.261719\"/>\n      <use xlink:href=\"#DejaVuSans-78\" x=\"182.275391\"/>\n      <use xlink:href=\"#DejaVuSans-29\" x=\"241.455078\"/>\n     </g>\n    </g>\n   </g>\n   <g id=\"line2d_17\">\n    <path d=\"M 61.03821 76.499955 \nL 69.236964 94.514954 \nL 73.760418 103.902804 \nL 77.435725 111.025494 \nL 80.545595 116.601825 \nL 83.372749 121.25224 \nL 85.917194 125.056542 \nL 88.461633 128.46779 \nL 90.723363 131.147662 \nL 92.985087 133.477965 \nL 94.964095 135.218459 \nL 96.943106 136.671355 \nL 98.922114 137.829523 \nL 100.61841 138.583333 \nL 102.314703 139.113706 \nL 104.010998 139.41874 \nL 105.707291 139.49733 \nL 107.403587 139.349203 \nL 109.099879 138.974884 \nL 110.796175 138.375721 \nL 112.492468 137.553873 \nL 114.471479 136.317591 \nL 116.450487 134.788325 \nL 118.429499 132.973559 \nL 120.691222 130.561421 \nL 122.952949 127.803469 \nL 125.497391 124.309473 \nL 128.041831 120.428485 \nL 130.868989 115.7007 \nL 133.97886 110.049684 \nL 137.37145 103.42491 \nL 141.612185 94.611088 \nL 146.983783 82.889298 \nL 159.140558 56.180186 \nL 163.381294 47.496889 \nL 166.773881 41.010321 \nL 169.883754 35.510553 \nL 172.71091 30.939082 \nL 175.255353 27.212769 \nL 177.799793 23.885414 \nL 180.061518 21.284541 \nL 182.323245 19.036857 \nL 184.302256 17.371218 \nL 186.281264 15.995197 \nL 188.260276 14.915524 \nL 189.956568 14.230013 \nL 191.652864 13.768606 \nL 193.349157 13.532962 \nL 195.045449 13.523935 \nL 196.741745 13.74155 \nL 198.438038 14.185031 \nL 200.134333 14.852777 \nL 201.830626 15.742385 \nL 203.809637 17.056357 \nL 205.788649 18.661487 \nL 207.767657 20.549905 \nL 210.02938 23.043056 \nL 212.29111 25.87816 \nL 214.835549 29.453709 \nL 217.379988 33.410073 \nL 220.207149 38.213636 \nL 223.317018 43.937414 \nL 226.992326 51.203645 \nL 231.233057 60.110022 \nL 237.170088 73.150859 \nL 238.583665 76.299279 \nL 238.583665 76.299279 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n   </g>\n   <g id=\"line2d_18\">\n    <path d=\"M 61.03821 139.5 \nL 62.73451 139.386634 \nL 64.430802 139.046944 \nL 66.127095 138.482151 \nL 67.823387 137.694291 \nL 69.51968 136.686198 \nL 71.498694 135.236619 \nL 73.477702 133.499351 \nL 75.45671 131.482902 \nL 77.71844 128.849255 \nL 79.980164 125.880755 \nL 82.524603 122.16466 \nL 85.351764 117.603546 \nL 88.461633 112.113856 \nL 91.854225 105.636554 \nL 95.812241 97.556954 \nL 100.61841 87.207896 \nL 117.015918 51.433579 \nL 120.691222 44.152416 \nL 124.083812 37.91322 \nL 127.193685 32.679444 \nL 130.020843 28.379571 \nL 132.565283 24.919649 \nL 134.827008 22.193875 \nL 137.088734 19.815473 \nL 139.067744 18.031344 \nL 141.046754 16.533591 \nL 143.025764 15.329557 \nL 144.722058 14.535813 \nL 146.418352 13.965069 \nL 148.114646 13.619386 \nL 149.81094 13.5 \nL 151.507235 13.607351 \nL 153.203528 13.941043 \nL 154.899823 14.499884 \nL 156.596117 15.281856 \nL 158.292411 16.284148 \nL 160.271421 17.727092 \nL 162.250431 19.457905 \nL 164.229441 21.468109 \nL 166.491166 24.094907 \nL 168.752891 27.056918 \nL 171.297333 30.766197 \nL 174.124489 35.320384 \nL 177.234362 40.803344 \nL 180.626949 47.274436 \nL 184.584972 55.348432 \nL 189.391137 65.69316 \nL 205.788649 101.474262 \nL 209.463949 108.76136 \nL 212.856541 115.00734 \nL 215.966411 120.24833 \nL 218.793572 124.555529 \nL 221.33801 128.022597 \nL 223.599734 130.755112 \nL 225.861464 133.140593 \nL 227.840472 134.931138 \nL 229.81948 136.43549 \nL 231.798495 137.646282 \nL 233.494787 138.445911 \nL 235.19108 139.022604 \nL 236.887372 139.374279 \nL 238.583665 139.499681 \nL 238.583665 139.499681 \n\" clip-path=\"url(#p4c53ea510f)\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #bf00bf; stroke-width: 1.5\"/>\n   </g>\n   <g id=\"patch_3\">\n    <path d=\"M 52.160938 145.8 \nL 52.160938 7.2 \n\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n   </g>\n   <g id=\"patch_4\">\n    <path d=\"M 247.460938 145.8 \nL 247.460938 7.2 \n\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n   </g>\n   <g id=\"patch_5\">\n    <path d=\"M 52.160938 145.8 \nL 247.460938 145.8 \n\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n   </g>\n   <g id=\"patch_6\">\n    <path d=\"M 52.160938 7.2 \nL 247.460938 7.2 \n\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n   </g>\n   <g id=\"legend_1\">\n    <g id=\"patch_7\">\n     <path d=\"M 59.160938 44.55625 \nL 119.207813 44.55625 \nQ 121.207813 44.55625 121.207813 42.55625 \nL 121.207813 14.2 \nQ 121.207813 12.2 119.207813 12.2 \nL 59.160938 12.2 \nQ 57.160938 12.2 57.160938 14.2 \nL 57.160938 42.55625 \nQ 57.160938 44.55625 59.160938 44.55625 \nz\n\" style=\"fill: #ffffff; opacity: 0.8; stroke: #cccccc; stroke-linejoin: miter\"/>\n    </g>\n    <g id=\"line2d_19\">\n     <path d=\"M 61.160938 20.298438 \nL 71.160938 20.298438 \nL 81.160938 20.298438 \n\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n    </g>\n    <g id=\"text_11\">\n     <!-- sin(x) -->\n     <g transform=\"translate(89.160938 23.798438) scale(0.1 -0.1)\">\n      <use xlink:href=\"#DejaVuSans-73\"/>\n      <use xlink:href=\"#DejaVuSans-69\" x=\"52.099609\"/>\n      <use xlink:href=\"#DejaVuSans-6e\" x=\"79.882812\"/>\n      <use xlink:href=\"#DejaVuSans-28\" x=\"143.261719\"/>\n      <use xlink:href=\"#DejaVuSans-78\" x=\"182.275391\"/>\n      <use xlink:href=\"#DejaVuSans-29\" x=\"241.455078\"/>\n     </g>\n    </g>\n    <g id=\"line2d_20\">\n     <path d=\"M 61.160938 34.976562 \nL 71.160938 34.976562 \nL 81.160938 34.976562 \n\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #bf00bf; stroke-width: 1.5\"/>\n    </g>\n    <g id=\"text_12\">\n     <!-- grad -->\n     <g transform=\"translate(89.160938 38.476562) scale(0.1 -0.1)\">\n      <defs>\n       <path id=\"DejaVuSans-67\" d=\"M 2906 1791 \nQ 2906 2416 2648 2759 \nQ 2391 3103 1925 3103 \nQ 1463 3103 1205 2759 \nQ 947 2416 947 1791 \nQ 947 1169 1205 825 \nQ 1463 481 1925 481 \nQ 2391 481 2648 825 \nQ 2906 1169 2906 1791 \nz\nM 3481 434 \nQ 3481 -459 3084 -895 \nQ 2688 -1331 1869 -1331 \nQ 1566 -1331 1297 -1286 \nQ 1028 -1241 775 -1147 \nL 775 -588 \nQ 1028 -725 1275 -790 \nQ 1522 -856 1778 -856 \nQ 2344 -856 2625 -561 \nQ 2906 -266 2906 331 \nL 2906 616 \nQ 2728 306 2450 153 \nQ 2172 0 1784 0 \nQ 1141 0 747 490 \nQ 353 981 353 1791 \nQ 353 2603 747 3093 \nQ 1141 3584 1784 3584 \nQ 2172 3584 2450 3431 \nQ 2728 3278 2906 2969 \nL 2906 3500 \nL 3481 3500 \nL 3481 434 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-72\" d=\"M 2631 2963 \nQ 2534 3019 2420 3045 \nQ 2306 3072 2169 3072 \nQ 1681 3072 1420 2755 \nQ 1159 2438 1159 1844 \nL 1159 0 \nL 581 0 \nL 581 3500 \nL 1159 3500 \nL 1159 2956 \nQ 1341 3275 1631 3429 \nQ 1922 3584 2338 3584 \nQ 2397 3584 2469 3576 \nQ 2541 3569 2628 3553 \nL 2631 2963 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \nQ 1497 1759 1228 1600 \nQ 959 1441 959 1056 \nQ 959 750 1161 570 \nQ 1363 391 1709 391 \nQ 2188 391 2477 730 \nQ 2766 1069 2766 1631 \nL 2766 1759 \nL 2194 1759 \nz\nM 3341 1997 \nL 3341 0 \nL 2766 0 \nL 2766 531 \nQ 2569 213 2275 61 \nQ 1981 -91 1556 -91 \nQ 1019 -91 701 211 \nQ 384 513 384 1019 \nQ 384 1609 779 1909 \nQ 1175 2209 1959 2209 \nL 2766 2209 \nL 2766 2266 \nQ 2766 2663 2505 2880 \nQ 2244 3097 1772 3097 \nQ 1472 3097 1187 3025 \nQ 903 2953 641 2809 \nL 641 3341 \nQ 956 3463 1253 3523 \nQ 1550 3584 1831 3584 \nQ 2591 3584 2966 3190 \nQ 3341 2797 3341 1997 \nz\n\" transform=\"scale(0.015625)\"/>\n       <path id=\"DejaVuSans-64\" d=\"M 2906 2969 \nL 2906 4863 \nL 3481 4863 \nL 3481 0 \nL 2906 0 \nL 2906 525 \nQ 2725 213 2448 61 \nQ 2172 -91 1784 -91 \nQ 1150 -91 751 415 \nQ 353 922 353 1747 \nQ 353 2572 751 3078 \nQ 1150 3584 1784 3584 \nQ 2172 3584 2448 3432 \nQ 2725 3281 2906 2969 \nz\nM 947 1747 \nQ 947 1113 1208 752 \nQ 1469 391 1925 391 \nQ 2381 391 2643 752 \nQ 2906 1113 2906 1747 \nQ 2906 2381 2643 2742 \nQ 2381 3103 1925 3103 \nQ 1469 3103 1208 2742 \nQ 947 2381 947 1747 \nz\n\" transform=\"scale(0.015625)\"/>\n      </defs>\n      <use xlink:href=\"#DejaVuSans-67\"/>\n      <use xlink:href=\"#DejaVuSans-72\" x=\"63.476562\"/>\n      <use xlink:href=\"#DejaVuSans-61\" x=\"104.589844\"/>\n      <use xlink:href=\"#DejaVuSans-64\" x=\"165.869141\"/>\n     </g>\n    </g>\n   </g>\n  </g>\n </g>\n <defs>\n  <clipPath id=\"p4c53ea510f\">\n   <rect x=\"52.160938\" y=\"7.2\" width=\"195.3\" height=\"138.6\"/>\n  </clipPath>\n </defs>\n</svg>\n"
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 44
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
